/*
 * FXGL - JavaFX Game Library. The MIT License (MIT).
 * Copyright (c) AlmasB (almaslvl@gmail.com).
 * See LICENSE for details.
 */

package com.windea.study.kotlin.fxgl.sample.sandbox

import com.almasb.fxgl.animation.*
import com.almasb.fxgl.app.*
import com.almasb.fxgl.dsl.*
import com.almasb.fxgl.particle.*
import javafx.scene.paint.*

/**
 * Using particles with source images and colorization.
 *
 * @author Almas Baimagambetov (AlmasB) (almaslvl@gmail.com)
 */
class RainSample : GameApplication() {
	override fun initSettings(settings: GameSettings) {}
	
	override fun initGame() {
		entityBuilder()
			.view(texture("underwater3.png", getAppWidth().toDouble(), getAppHeight().toDouble()))
			.buildAndAttach()
		
		// example - multiply color with existing
		val emitter = ParticleEmitters.newRainEmitter(getAppWidth() / 2)
		emitter.setSourceImage(texture("rain.png").multiplyColor(Color.BLUE))
		
		entityBuilder()
			.with(ParticleComponent(emitter))
			.buildAndAttach()
		
		// example - set color
		val emitter2 = ParticleEmitters.newRainEmitter(getAppWidth() / 2)
		emitter2.setSourceImage(texture("rain.png").toColor(Color.BLUE))
		
		emitter2.interpolator = Interpolators.EXPONENTIAL.EASE_OUT()
		
		entityBuilder()
			.at((getAppWidth() / 2).toDouble(), 0.0)
			.with(ParticleComponent(emitter2))
			.buildAndAttach()
	}
}

fun main(args: Array<String>) {
	GameApplication.launch(RainSample::class.java, args)
}

